package com.fr.report.cellElement.core;

import com.fr.base.FCloneable;
import java.io.InvalidObjectException;
import java.io.Serializable;

public class EM
  implements Serializable, Cloneable
{
  private static final long serialVersionUID = -4670506674032047134L;
  public static EM EMPTY_ATTR = new EM()
  {
    private static final long serialVersionUID = 4811251772990761188L;

    public int size()
    {
      return 0;
    }

    public Object get(CellElementAttribute paramCellElementAttribute)
    {
      return null;
    }

    public void put(CellElementAttribute paramCellElementAttribute, Object paramObject)
    {
      throw new UnsupportedOperationException();
    }

    public void remove(CellElementAttribute paramCellElementAttribute)
    {
    }

    private Object readResolve()
      throws InvalidObjectException
    {
      return EMPTY_ATTR;
    }

    public Object clone()
      throws CloneNotSupportedException
    {
      return EMPTY_ATTR;
    }
  };
  protected Object[] valArray = new Object[0];
  protected int size = 0;

  public int size()
  {
    return this.size;
  }

  public Object get(CellElementAttribute paramCellElementAttribute)
  {
    int i = paramCellElementAttribute.idx;
    return ((this.valArray.length > i) ? this.valArray[i] : null);
  }

  public void put(CellElementAttribute paramCellElementAttribute, Object paramObject)
  {
    if (paramObject != null)
    {
      Object localObject = get(paramCellElementAttribute);
      if (localObject != null)
      {
        this.valArray[paramCellElementAttribute.idx] = paramObject;
      }
      else
      {
        ensureCapacity(paramCellElementAttribute.idx + 1);
        this.valArray[paramCellElementAttribute.idx] = paramObject;
        this.size += 1;
      }
    }
    else
    {
      remove(paramCellElementAttribute);
    }
  }

  public void remove(CellElementAttribute paramCellElementAttribute)
  {
    Object localObject = get(paramCellElementAttribute);
    if (localObject != null)
    {
      this.valArray[paramCellElementAttribute.idx] = null;
      this.size -= 1;
    }
  }

  private void ensureCapacity(int paramInt)
  {
    if (this.valArray.length < paramInt)
    {
      Object[] arrayOfObject = this.valArray;
      this.valArray = new Object[paramInt];
      System.arraycopy(arrayOfObject, 0, this.valArray, 0, arrayOfObject.length);
    }
  }

  public Object lightClone()
    throws CloneNotSupportedException
  {
    EM localEM = (EM)super.clone();
    localEM.valArray = new Object[this.valArray.length];
    for (int i = 0; i < this.valArray.length; ++i)
      localEM.valArray[i] = this.valArray[i];
    return localEM;
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    EM localEM = (EM)super.clone();
    localEM.valArray = new Object[this.valArray.length];
    for (int i = 0; i < this.valArray.length; ++i)
    {
      Object localObject = this.valArray[i];
      if (localObject instanceof FCloneable)
        localEM.valArray[i] = ((FCloneable)this.valArray[i]).clone();
      else
        localEM.valArray[i] = this.valArray[i];
    }
    return localEM;
  }
}